var app = getApp()
var util = require("../../utils/util.js")
var tuiModel = require("../../model/tuiModel.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tuiSetting:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var tui = app.data.tempTui
    tui.money = tui.money.toFixed(2)
    this.setData({
      goods: app.data.tempGoods,
      tui: app.data.tempTui
    })
    this.init()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {
    var tui = this.data.tui
    var title = tui.title
    var path = ""
    if ([1, 2, 3, 4, 5, 6, 7, 8, 9].indexOf(tui.type) != -1) path = "/pages/goods_info/goods_info"
    if ([13, 14, 15, 16].indexOf(tui.type) != -1) path = "/pages/card_info/card_info"
    path = path + "?cusId=" + app.data.user.id + "&id=" + tui.pid + "&type=" + tui.type
    return {
      title: title,
      path: path
    }
  },

  init() {
    var that = this
    tuiModel.getTuiSetting(res => {
      if (res.status == 0) {
        console.log(res.data)
        that.setData({
          tuiSetting: res.data
        })
      }
    })
  }
})